/*
 * montage.cpp
 *
 *  Created on: Aug 1, 2009
 *      Author: zaca
 */

#include <biosignal/biosignal.h>
#include <biosignal/montage/montage.h>
#include <biosignal/montage/channel.h>

#include <iostream>
namespace biosignal {

namespace montage {

Montage::Montage(const BioSignal * biosignal) :
	m_biosignal(biosignal) {

}

Montage::~Montage() {
}

void Montage::addChannel( Channel * channel ) {
	m_channels.push_back( ChannelType(channel) );
}

const std::list< ChannelType >& Montage::channels() const {
	return m_channels;
}

std::vector<ChannelDataType> Montage::create_channels_data(
		const DataFrame* dataframe) const {
	std::vector<ChannelDataType> result;
	std::list<ChannelType>::const_iterator it=m_channels.begin();
	for( it=m_channels.begin(); it!= m_channels.end(); ++it ) {
		result.push_back( (*it)->channel_data( dataframe ) );
	}
	return result;
}


ReferentialMontage::ReferentialMontage(const BioSignal * biosignal) :
	Montage(biosignal) {
	SignalsGroup signals_group = biosignal->signals_group();
	SignalsGroup::const_iterator it;
	for (it = signals_group.begin(); it != signals_group.end(); ++it) {
		if ((*it)->enabled()) {
			RefChannel * ref_channel = new RefChannel(*it);
			addChannel(ref_channel);
		}
	}

}


ReferentialMontage::~ReferentialMontage() {
//	std::cout << " deleting ReferentialMontage  " << this << std::endl;
}

}
}
